//Francisco "Kiko" Olvera
//Power up "Swap"
//Swap places with another player
//PUSwap.h

#include "PUSwap.h"
#include "input.h"
#include "Controller.h"
#include "ENUM.h"


PUSwap::PUSwap()
{
	PU_name = "Swap Places Power-Up";
}
int PUSwap::Execute(Input* input, Player* player, Text * text)
{
	control = Controller::Instance();
	allPlayers = control->getPlayers();
	size = control->getNumPlayers();

	//Set font object for this power-up
	text->setText("PICK THE PLAYER YOU WANT TO SWAP WITH!\n"
				  "Hold <CTRL> for help.");
	if(input->KeyDown(DIK_LCONTROL) || input->KeyDown(DIK_RCONTROL))
	{
		text->setText(	"* Use <SHIFT> keys to look at your current goal.\n"
						"* Using the keyboard,\n"
						"  press the number key for the player you want to swap positions with.");
	}

	if(size >= 4 && input->KeyPressed(DIK_4))
	{
		if(player != &allPlayers[3])
		{
			temp = allPlayers[3].getCurrentTile();
			allPlayers[3].SetBoardPosition(player->getCurrentTile());
			player->SetBoardPosition(temp);
			return MOVE;
		}
	}
	if(size >= 3 && input->KeyPressed(DIK_3))
	{
		if(player != &allPlayers[2])
		{
			temp = allPlayers[2].getCurrentTile();
			allPlayers[2].SetBoardPosition(player->getCurrentTile());
			player->SetBoardPosition(temp);
			return MOVE;
		}
	}
	if(size >= 2 && input->KeyPressed(DIK_2))
	{
		if(player != &allPlayers[1])
		{
			temp = allPlayers[1].getCurrentTile();
			allPlayers[1].SetBoardPosition(player->getCurrentTile());
			player->SetBoardPosition(temp);
			return MOVE;
		}
	}
	if(size >= 1 && input->KeyPressed(DIK_1))
	{
		if(player != &allPlayers[0])
		{
			temp = allPlayers[0].getCurrentTile();
			allPlayers[0].SetBoardPosition(player->getCurrentTile());
			player->SetBoardPosition(temp);
			return MOVE;
		}
	}
	return STAY;
}